import { Input } from "antd"
import { Rule } from "antd/es/form"
import { FC } from "react"

import { SFormItem } from "@/components/common"
import { useLocale } from "@/locales"
import { notAllowSpecialCharacters } from "@/utils/validate"

interface TopProxyNameInputProps {
	isHideLabel?: boolean
	onChange?: (text: string) => void
	rules?: Rule[]
}

const TopProxyNameInput: FC<TopProxyNameInputProps> = ({ isHideLabel = false, onChange, rules }) => {
	const { newFormat } = useLocale()

	const onNotAllow = (value: string) => {
		onChange && onChange(value)
	}

	return (
		<SFormItem name="topProxyName" label={isHideLabel ? "" : newFormat("funds.fund_audit.top_proxy_name")} rules={rules}>
			<Input allowClear placeholder={newFormat("common.please_enter")} onChange={e => notAllowSpecialCharacters(e, onNotAllow)} />
		</SFormItem>
	)
}

export default TopProxyNameInput
